<?php
// 获得当前填写诊单的基本信息
// header("content-type:text/html;charset=UTF-8");
include_once("conn.php");
include_once("d_getLoginInfo.php");
if ($_GET['orderID'] == "") {
    echo "<script>alert('参数错误');location='doc_AcceptInfo.php';</script>";
    exit();
}
$casesID = $_GET['orderID'];
//设置中国时区
date_default_timezone_set('Asia/Shanghai');
// 获取当前日期
$getNowDate = date('Y-m-d');

$select_orderinfo = "SELECT * FROM order_infos  JOIN department_infos ON order_infos.orderType = department_infos.department_ID WHERE orderID = '" . $casesID . "'";
if ($result_orderinfo = mysqli_query($connect_DB, $select_orderinfo)) {
    if(mysqli_num_rows($result_orderinfo) == 0){
        echo "<script>alert('参数错误!');location='doc_AcceptInfo.php';</script>";
        exit();
    }
    $row_orderinfo = mysqli_fetch_object($result_orderinfo);
    $select_petinfo = "SELECT * FROM pet_infos WHERE pet_ID = '" . $row_orderinfo->pet_ID . "'";
    if ($result_petinfo = mysqli_query($connect_DB, $select_petinfo)) {
        $row_petinfo = mysqli_fetch_object($result_petinfo);
        echo "
        <div class='table-top-div'>
            <img src='../public/pic/logo-h-b.png'>
            <span>单号：<input type='text' name='cases_ID' value='" . $casesID . "' readonly></span>
            <h4>就 诊 记 录 单</h4>
        </div>
        <div class='table-infos-div'>
            <div>昵称：<input type='text' name='cases_petName' value='" . $row_petinfo->pet_Name . "' readonly></div>
            <div>类型：<input type='text' name='cases_petType' value='" . $row_petinfo->pet_Type . "' readonly></div>
            <div>服务：<input type='text' name='cases_orderType' value='" . $row_orderinfo->orderType . "-" . $row_orderinfo->department_Name . "' readonly></div>
        </div>
        <div class='table-result-div'>
            诊断结果：<textarea name='caese_result' id='caese_result' placeholder='请在此填写诊断结果...' required></textarea>
        </div>
        <div class='table-result-div'>
            解决方案：<textarea name='caese_deal' id='caese_deal' placeholder='请在此填写解决方案...' required></textarea>
        </div>
        <div class='table-bottom-div'>
            <div>医生：<input type='text' name='cases_docName' value='" . $doc_Name . "' readonly></div>
            <div>日期：<input type='text' name='cases_date'  value='" . $getNowDate . "'readonly></div>
        </div>
        <input type='hidden' name='cases_petID' value='" . $row_petinfo->pet_ID . "'>
        <input type='hidden' name='cases_userID' value='" . $row_orderinfo->user_ID . "'>
        <div class='col-12'>
            <button class='btn btn-primary' type='submit' onclick='return checkCasesForm()'>提交诊单</button>
        </div>
        ";
    } else {
        echo "<script>alert('查询出错！');location='doc_AcceptInfo.php';</script>";
    }
}
else {
    echo "<script>alert('查询出错！');location='doc_AcceptInfo.php';</script>";
}

$connect_DB->close();
?>
